﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace JiaBao.Core.Infrastructure
{
    /// <summary>
    /// 类型查找器
    /// </summary>
    public interface ITypeFinder
    {
        /// <summary>
        /// 获取程序下所有程序集
        /// </summary>
        /// <returns></returns>
        IList<Assembly> GetAssemblies();

        /// <summary>
        /// 查找指定类型
        /// </summary>
        /// <param name="assignTypeFrom"></param>
        /// <param name="onlyConcreteClasses"></param>
        /// <returns></returns>
        IEnumerable<Type> FindClassesOfType(Type assignTypeFrom, bool onlyConcreteClasses = true);

        /// <summary>
        /// 查找指定类型
        /// </summary>
        /// <param name="assignTypeFrom">指定类型</param>
        /// <param name="assemblies">查找程序集范围</param>
        /// <param name="onlyConcreteClasses">仅实体类</param>
        /// <returns></returns>
        IEnumerable<Type> FindClassesOfType(Type assignTypeFrom, IEnumerable<Assembly> assemblies, bool onlyConcreteClasses = true);

        /// <summary>
        /// 查找指定类型
        /// </summary>
        /// <typeparam name="T">指定类型</typeparam>
        /// <param name="onlyConcreteClasses">仅实体类</param>
        /// <returns></returns>
        IEnumerable<Type> FindClassesOfType<T>(bool onlyConcreteClasses = true);

        /// <summary>
        /// 查找指定类型
        /// </summary>
        /// <typeparam name="T">指定类型</typeparam>
        /// <param name="assemblies">查找程序集范围</param>
        /// <param name="onlyConcreteClasses">仅实体类</param>
        /// <returns></returns>
        IEnumerable<Type> FindClassesOfType<T>(IEnumerable<Assembly> assemblies, bool onlyConcreteClasses = true);
    }
}
